package com.cy.pj.sys.controller;

import com.cy.pj.common.vo.JsonResult;
import com.cy.pj.sys.entity.SysDept;
import com.cy.pj.sys.service.SysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/dept")
@RestController
public class SysDeptController {
    @Autowired
    private SysDeptService sysDeptService;
    //获取部门信息
    @RequestMapping("/doFindObjects")
    public JsonResult doFindObjects(){
        return new JsonResult(sysDeptService.findObjects());
    }

    //返回ZTree树结构数据
    @RequestMapping("/doFindZTreeNodes")
    public JsonResult doFindZTreeNodes(){
        return new JsonResult(sysDeptService.findZTreeNodes());
    }

    //修改部门信息
    @RequestMapping("/doUpdateObject")
    public JsonResult doUpdateObject(SysDept entity){
        sysDeptService.updateObject(entity);
        return new JsonResult("update ok");
    }

    //保存部门信息
    @RequestMapping("/doSaveObject")
    public JsonResult doSaveObject(SysDept entity){
        sysDeptService.saveObject(entity);
        return new JsonResult("save ok");
    }

    //删除部门信息
    @RequestMapping("/doDeleteObject")
    public JsonResult doDeleteObject(Integer id){
        sysDeptService.deleteObject(id);
        return new JsonResult("delete ok");
    }
}
